home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 039a / bccapp.zip / VSCROLL.C < prev    next >
C/C++ Source or Header  |  1991-09-15  |  3KB  |  156 lines

  1. /*
  2.  *
  3.  * Virtual Scroll Boxes.  Takes entries from a file..
  4.  *
  5.  * (C) 1990 Vision Software
  6.  *
  7.  * $Id: vscroll.c 1.2001 91/04/25 15:08:02 pcalvin release $
  8.  *
  9.  * Comments:
  10.  *
  11.  * This class provides selection boxes that come from DATABASEs.  As such
  12.  * the true dimension of each box cannot be determined at compile time.
  13.  *
  14.  * Bugs:
  15.  *
  16.  *    None docuemnted
  17.  *
  18.  */
  19. #include <stdlib.h>
  20. #include <conio.h>
  21. #include <string.h>
  22. #include <ctype.h>
  23.  
  24. #include <stdhdr.h>
  25. #include <adl.h>
  26. #include <menu.h>
  27.  
  28. #include "lowlevel.h"
  29.  
  30. /*
  31.  * Sets up the dimensions and entries for the Virtual scroll box
  32.  */
  33. VSCROLL::VSCROLL(ROW row,COL col,CENT centView,DATABASE &rdtbOriginal,SZ sz,CCH cch,SZ szTitle) : SCROLL(row,col,centError,pentNil,centView,szTitle), rdtb(rdtbOriginal)
  34.     {
  35.     szIndex = (sz == szNil) ? rdtb.SzIndex() : sz;
  36.     cchIndex = (cch == cchNil) ? rdtb.CchIndex() : cch;
  37.     
  38.     /*
  39.      * Start at the first record..
  40.      */
  41.     if (rdtb.FFirst())
  42.         Verify(rdtb.FMark());
  43.     }
  44.  
  45. /*
  46.  * Redraw.  Because virtual scroll boxes are disk-based, Redraw() from
  47.  * popup does not function for our needs..
  48.  */
  49. VOID VSCROLL::Redraw(VOID)
  50.     {
  51.     Verify(rdtb.FGotoMark());
  52.  
  53.     CENT cent = centNil;
  54.  
  55.     /*
  56.      * Display over the entire window, unless we run out of records..
  57.      */
  58.     do
  59.         {
  60.         Display(cent,pentNil,wnd,fFalse);
  61.         }
  62.     while (rdtb.FNext() && ++cent < centViewMax);
  63.  
  64.     Verify(rdtb.FGotoMark());
  65.     }
  66.  
  67. /*
  68.  * Even though PENT is never used, it must be a formal parameter so
  69.  * that THIS display is called from POPUP..
  70.  */
  71. VOID VSCROLL::Display(CENT cent,PENT pent,WINDOW &rwnd,BOOL fSelect)
  72.     {
  73.     /*
  74.      * Display Index entry.  Derived classes may overide this function
  75.      */
  76.     CO coBack = (fSelect) ? coGreen : coCyan;
  77.     SZ sz = SzTempPaddedFromSzCch(szIndex,cchIndex);
  78.  
  79.     /*
  80.      * On screen..
  81.      */
  82.     rwnd.SetRowCol(cent,0);
  83.     rwnd.PutCh(chSpace,coBlack,coBack);
  84.     rwnd.Say(sz,coBlack,coBack);
  85.     rwnd.PutCh(chSpace,coBlack,coBack);
  86.     }
  87.  
  88. BOOL VSCROLL::FHandleCd(CENT &rcent,CD cd,PENT pent,WINDOW &rwnd)
  89.     {
  90.     BOOL fContinue = fTrue;
  91.     /*
  92.      * Defaults to no exit, must prove otherwise.
  93.      */
  94.     switch (cd)
  95.         {
  96.     case cdReturn:
  97.         fContinue = fFalse;
  98.         break;
  99.     case cdCursorUp:
  100.         /*
  101.          * Erase old highlight..
  102.          */
  103.         Display(rcent,pentNil,rwnd,fFalse);
  104.  
  105.         /*
  106.          *    Attempt move to previous.  Scroll window if necessary 
  107.          */
  108.         if (rdtb.FPrevious())
  109.             {
  110.             Verify(rdtb.FMark());
  111.             
  112.             if (rcent == 0)
  113.                 rwnd.ScrollDrow(-1);
  114.             else
  115.                 rcent--;
  116.             }
  117.         break;
  118.     case cdCursorDown:
  119.  
  120.         /*
  121.          * Erase old..
  122.          */
  123.         Display(rcent,pentNil,rwnd,fFalse);
  124.  
  125.         /*
  126.          *    Attempt move to next, scroll window as necessary
  127.          */
  128.         if (rdtb.FNext())
  129.             {
  130.             Verify(rdtb.FMark());
  131.             
  132.             if (rcent+1 < centViewMax)
  133.                 rcent++;
  134.             else
  135.                 rwnd.ScrollDrow(1);
  136.             }
  137.  
  138.         break;
  139.     default:
  140.         fContinue = POPUP::FHandleCd(rcent,cd,pent,rwnd);
  141.         break;
  142.         }
  143.  
  144.     return (fContinue);
  145.     }
  146.  
  147. ROW VSCROLL::CrowFromCentPent(CENT centMac,PENT pent)
  148.     {
  149.     return (centViewMax);
  150.     }
  151.  
  152. ROW VSCROLL::CcolFromCentPent(CENT centMac,PENT pent)
  153.     {
  154.     return (cchIndex);
  155.     }
  156.